﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InfraTools
{
    public partial class FrmSettings : Form
    {
        
        public Glpi glpicon { get; set; }

        public FrmSettings()
        {
            InitializeComponent();
        }
       
 private void FrmSettings_Load(object sender, EventArgs e)
        {
            



            Properties.Settings.Default.Reload();
            TxtSetSccmServer.Text = Properties.Settings.Default.SccmServer;
            TxtSetSccmUsr.Text = Properties.Settings.Default.SccmUsr;
            TxtSetSccmPass.Text = Properties.Settings.Default.SccmPwd;
            TxtSetSccmSiteCode.Text = Properties.Settings.Default.SccmSitecode;
            txtGlpiWS.Text = Properties.Settings.Default.GlpiWebServiceUrl;
      
                if (glpicon.isConnected(false))
                {
                    GbGlpiLoggedSettings.Show();
                    cmbBareMetal.DataSource = glpicon.getCmbValues("state");
                    cmbBareMetal.SelectedValue = Properties.Settings.Default.GlpiBareMetalStatus;
                    cmbStaged.DataSource = glpicon.getCmbValues("state");
                    cmbStaged.SelectedValue = Properties.Settings.Default.GlpiStagedStatus;
                    cmbInUse.DataSource = glpicon.getCmbValues("state");
                    cmbInUse.SelectedValue = Properties.Settings.Default.GlpInUseStatus;



                }
                else
                {
                    GbGlpiLoggedSettings.Hide();
                }
            
            
            
        }


        private void BtnSetOK_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.SccmServer = TxtSetSccmServer.Text;
            Properties.Settings.Default.SccmUsr = TxtSetSccmUsr.Text;
            Properties.Settings.Default.SccmPwd = TxtSetSccmPass.Text;
            Properties.Settings.Default.SccmSitecode = TxtSetSccmSiteCode.Text;
            Properties.Settings.Default.GlpiWebServiceUrl = txtGlpiWS.Text;
            
                if (glpicon.isConnected(false))
                {
                    Properties.Settings.Default.GlpiBareMetalStatus = (int)cmbBareMetal.SelectedValue;
                    Properties.Settings.Default.GlpiStagedStatus = (int)cmbStaged.SelectedValue;
                    Properties.Settings.Default.GlpInUseStatus = (int)cmbInUse.SelectedValue;
                    Properties.Settings.Default.Save();


                }
            
            
            Properties.Settings.Default.Save();
            
            this.Close();
        }

        private void BtnSetCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void BtnSetReset_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Reset();
            Properties.Settings.Default.Save();
            this.Refresh();
            
        }

        private void TxtSetSccmPass_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
        {

        }










    }
}
